package main

import "fmt"

type Useber interface {
	start()
	stop()
}

// 电脑
type Computer struct{}

func (c Computer) work(usb Useber) {

	if _, ok := usb.(Phone); ok {
		usb.start()
	} else {
		usb.stop()
	}

}

// 手机
type Phone struct {
	Name string
}

func (p Phone) start() {
	fmt.Println(p.Name, "启动")
}
func (p Phone) stop() {
	fmt.Println(p.Name, "关机")
}

// 照相机
type Camera struct{}

func (c Camera) start() {
	fmt.Println("相机启动")
}
func (c Camera) stop() {
	fmt.Println("相机关机")
}

func main() {
	//实例化一个电脑
	var computer = Computer{}
	//实例化一个手机
	var phone = Phone{
		Name: "华为",
	}

	camera := Camera{}

	computer.work(phone)
	computer.work(camera)
}
